[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
UNION            Define a Union                                TASM Directive

   name UNION     TASM Ideal Mode:   UNION name
   fields                            fields
   [name] ENDS                       ENDS [name]

     A UNION may be thought of as a STRUC, except that all of its members
     start at the beginning of the union and overlap. You can refer to
     the set of fields that result with one name. (The length of the
     union is the length of its largest member.)

     UNIONs are useful to get around strong typing requirements, because
     you can address the data in a union as though it were any of the
     contained data types.

     The fields indicated above are defined with the normal data
     allocation directives like DB or DD. For example, to define a union
     named MY_UNION, you can use this definition:

                        MY_UNION UNION
                        MEM_BYTE    DB ?
                        MEM_WORD    DW ?
                        MEM_DWORD   DD ?
                        MY_UNION ENDS

     Every field (MEM_BYTE, MEM_WORD, MEM_DWORD) in MY_UNION begins at
     the same place, at offset 0 from the beginning of the union. You can
     refer to the memory area defined by MY_UNION with any of the above
     field names.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson